package bussinessService.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.text.StyledEditorKit.BoldAction;

import domain.vo.BlockVO;
import domain.vo.queryObject;
import module.BasicBanKuai;
import bussinessService.basicBankuaiBussinessService;

/**
 * 
* @ClassName: BasicBanKuaiBussinessServiceImpl
* @Description: 系统基本信息的板块服务实现类
* @author chenchao
* @date 2013-10-30 上午03:43:39
*
 */
public class BasicBanKuaiBussinessServiceImpl  implements basicBankuaiBussinessService{

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#deleteT(int)
	 */

	public void deleteT(int id) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#deleteT(java.lang.Object)
	 */
	public void deleteT(BasicBanKuai t) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#getAll()
	 */
	public List<BlockVO> getAll() throws SQLException {
		List<BlockVO> tempVOS = new ArrayList<BlockVO>(); 
		List<BasicBanKuai> results = bankuaiService.getAll();
		for(BasicBanKuai bbk : results) {
			BlockVO vo = new BlockVO();
			vo.setBlockId(bbk.getBb_id());
			vo.setBlockName(bbk.getBb_name());
			vo.setId(bbk.getBb_id());
			vo.setText(bbk.getBb_name());
			tempVOS.add(vo);
		}
		return tempVOS;
	}

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#getById(java.lang.String)
	 */
	public BasicBanKuai getById(String id) throws SQLException {
		// TODO Auto-generated method stub
		return bankuaiService.getById(id);
	}

	/* (non-Javadoc)
	 * @see bussinessService.basicbussinessService#merageObject(java.lang.Object)
	 */
	public void merageObject(BasicBanKuai basicBanKuai) throws SQLException {
		if (basicBanKuai.getBb_id() == 0) {
			bankuaiService.insertObject(basicBanKuai);
		} else {
			bankuaiService.updateObject(basicBanKuai);
		}
		
	}

	public int countByQueryObject(queryObject queryObject) {
		// TODO Auto-generated method stub
		return 0;
	}

	public List<BlockVO> getObjectByQueryObject(queryObject queryObject) throws SQLException {
		List<BlockVO> tempVOS = new ArrayList<BlockVO>(); 
		List<BasicBanKuai> results = bankuaiService.getObjectByQueryObject(queryObject);
		BlockVO votop = new BlockVO();
		votop.setBlockId(-1);
		votop.setBlockName("板块不限");
		votop.setSelected(true);
		tempVOS.add(votop);
		for(BasicBanKuai bbk : results) {
			BlockVO vo = new BlockVO();
			vo.setBlockId(bbk.getBb_id());
			vo.setBlockName(bbk.getBb_name());
			vo.setId(bbk.getBb_id());
			vo.setText(bbk.getBb_name());
			tempVOS.add(vo);
		}
		return tempVOS;
	}

}
